package mqtt

import (
	"crypto/hmac"
	"crypto/sha1"
	"encoding/base64"
	"log"
)

func HMACSHA1(key, dataToSign string) string {
	mac := hmac.New(sha1.New, []byte(key))
	mac.Write([]byte(dataToSign))
	result := mac.Sum(nil)
	return base64.StdEncoding.EncodeToString(result)
}

//捕捉错误
func stack() {
	if err := recover(); err != nil {
		log.Println("[错误]", err)
	}
}
